package com.ljpz.manage.controller.api;

import com.ljpz.manage.pojo.ItemParamItem;
import com.ljpz.manage.service.ItemParamItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by liujunchen on 2016/12/18.
 */
@RequestMapping("/api/item/param/item")
@Controller
public class ApiItemParamItemController {
    @Autowired
     private ItemParamItemService  itemParamItemService  ;
    @RequestMapping(value = "{itemId}",method = RequestMethod.GET)
    public ResponseEntity<ItemParamItem>queryItemParamItemByItemId(@PathVariable("itemId")Long itemId ){
        try {
            ItemParamItem  itemParamItem  =  new ItemParamItem();
            itemParamItem.setItemId(itemId);
            itemParamItem  = this.itemParamItemService.queryOne(itemParamItem)  ;
            if (null==itemParamItem)
                return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null) ;
            return    ResponseEntity.ok(itemParamItem);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null) ;
    }
}
